/**
 * 分页查询函数
 * @param {查询页数} page
 * @param {查询条数} limit
 * @param {总数据数} total
 * @returns
 */
exports.limitCallback = function (page, limit, total) {
    if (page <= 1) {
        return parseInt((total + limit - 1) / limit - 1)
    } else {
        return (page * limit) - limit
    }
}

exports.echartBubble = function (list) {
    let newlist = []
    let xnum1 = 0
    let xnum2 = 30
    for (let i = 0; i < list.length; i++) {
        let size = randomNum(25,35)
        xnum1 += size + 25
        if(i%2===0){
            xnum2 +=  randomNum(45,60)
        }else{
            xnum2 -=  randomNum(45,60)
        }

        newlist.push({
            name: list[i].name,
            data: [
                [xnum1, xnum2,size, list[i].name]
            ]
        })
    }
    return newlist
}

function randomNum(minNum, maxNum) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * minNum + 1);
            break;
        case 2:
            return parseInt(Math.random() * (maxNum - minNum + 1) + minNum);
            break;
        default:
            return 0;
            break;
    }
}
